.TH IOCTL 2 
.SH NAME
ioctl, stty, gtty \- control device
.SH SYNOPSIS
.B #include <sgtty.h>
.PP
.B ioctl(fildes, request, argp)
.br
.B struct sgttyb *argp;
.PP
.B stty(fildes, argp)
.br
.B struct sgttyb *argp;
.PP
.B gtty(fildes, argp)
.br
.B struct sgttyb *argp;
.SH DESCRIPTION
.I Ioctl
performs a variety of functions
on character special files (devices).
The writeups of various devices
in section 4 discuss how
.I ioctl
applies to them.
.PP
For certain status setting and status inquiries
about terminal devices, the functions
.I stty
and
.I gtty
are equivalent to
.RS
.B ioctl(fildes, TIOCSETP, argp)
.br
.B ioctl(fildes, TIOCGETP, argp)
.RE
.LP
respectively; see
.IR tty (4).
.PP
The following two calls, however, apply to any open file:
.PP
.RS
.B ioctl(fildes, FIOCLEX, NULL);
.br
.B ioctl(fildes, FIONCLEX, NULL);
.RE
.LP
The first causes the file to be closed automatically during
a successful
.I exec
operation;
the second reverses the effect of the first.
.SH "SEE ALSO"
stty(1), tty(4), exec(2)
.SH DIAGNOSTICS
Zero is returned if the call was successful;
\-1 if the file descriptor does not refer to
the kind of file for which it was intended.
.SH BUGS
Strictly speaking,
since 
.I ioctl
may be extended in different ways to devices with
different properties,
.I argp
should have an open-ended declaration like
.IP
.B union { struct sgttyb
.RB ... ;
\&...
.B } *argp;
.PP
The important thing is that the size is fixed by `struct sgttyb'.
.SH ASSEMBLER
(ioctl = 54.)
.br
.B sys ioctl; fildes; request; argp
.PP
(stty = 31.)
.br
(file descriptor in r0)
.br
.B stty; argp
.PP
(gtty = 32.)
.br
(file descriptor in r0)
.br
.B sys gtty; argp
